from lxml.html import fromstring, tostring
from datetime import datetime
from urllib2 import urlopen

from django.utils.dateformat import format
from django.template import Context, loader

from shackapi.settings import SHACK_URLS

class ShackThread(object):
    
    def __init__(self):
        self.threadid = 0
        self.posts = []
        self.totalPages = None
        self.currentPage = 1
        self.title = ""
        self.storyID = 0
        
    def load_thread(self, threadid):
        pass
    
def render_subthread(info):
    if not isinstance(info, dict):
        raise TypeError("Can only render using a dict")
    t = loader.get_template('stories.xml')
    c = Context(info)
    return = t.render(c)